/**
 * May 5, 2014 10:03:22 AM
 */
package elitech.vietnam.copyweatherfashion.entities;

import com.google.gson.annotations.SerializedName;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;

/**
 * @author Cong
 *
 */
public class Post {

	@SerializedName("id")
	public int Id;
	
	@SerializedName("id_store")
	public int StoreId;
	
	@SerializedName("date")
	public String Date;
	
	@SerializedName("title")
	public String Title;
	
	@SerializedName("price")
	public double Price;
	
	@SerializedName("link")
	public String Link;
	
	@SerializedName("image")
	public String Image;
	
	@SerializedName("content")
	public String Content;
	
	@SerializedName("create_day")
	public String CreateDate;
	
	@SerializedName("status")
	public int Status;
	
	@SerializedName("likes")
	public int Likes;
	
	@SerializedName("islike")
	private int Liked;
	
	@SerializedName("comments")
	public int Comments;
	
	@SerializedName("type")
	public int Type;
	
	@SerializedName("ip")
	public String Ip;
	
	public Date Date() {
		try {
			return new SimpleDateFormat("yyyy-MM-dd", Locale.getDefault()).parse(Date);
		} catch (ParseException e) {
			e.printStackTrace();
			return null;
		}
	}
	
	public Date CreateDate() {
		try {
			return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault()).parse(CreateDate);
		} catch (ParseException e) {
			e.printStackTrace();
			return null;
		}
	}
	
	public boolean Liked() {
		return Liked > 0;
	}
	
	public void Liked(boolean liked) {
		Liked = (liked) ? 1 : 0;
	}
}
